package com.bw.aop;

import com.alibaba.fastjson.JSON;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Controller;

@Component
@Aspect
public class MyAOP {


    @Around("execution(* com.bw.service.*.*(..))")
    public Object aop(ProceedingJoinPoint joinPoint) throws Throwable {

        String name = joinPoint.getSignature().getName();
        System.out.println("方法名称 " + name);

        Object[] args = joinPoint.getArgs();
        System.out.println("方法入参 " + JSON.toJSONString(args));
        long l = System.currentTimeMillis();
        Object proceed = joinPoint.proceed();
        long l2 = System.currentTimeMillis();
        System.out.println("方法执行耗时 " + (l2 - l));

        System.out.println("方法返参 " + JSON.toJSONString(proceed));

        return proceed;

    }
}
